package zasm.zasm.util;

import java.util.Iterator;
import java.util.NoSuchElementException;

public class SingletonIterator<E> implements Iterator<E> {

	private final E	singleton;
	private boolean	hasNext	= true;

	public SingletonIterator(final E singleton) {
		this.singleton = singleton;
	}

	@Override
	public final boolean hasNext() {
		return hasNext;
	}

	@Override
	public final E next() {
		if (hasNext) {
			hasNext = false;
			return singleton;
		} else {
			throw new NoSuchElementException();
		}
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}

}
